package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.LhkRoom;
import com.ruoyi.system.service.ILhkRoomService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 房间信息管理Controller
 * 
 * @author fzb
 * @date 2025-05-29
 */
@RestController
@RequestMapping("/system/room")
public class LhkRoomController extends BaseController
{
    @Autowired
    private ILhkRoomService lhkRoomService;

    /**
     * 查询房间信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:hotel_room:list')")
    @GetMapping("/list")
    public TableDataInfo list(LhkRoom queryParams)
    {
        System.out.println(queryParams);
        startPage();
        List<LhkRoom> list = lhkRoomService.selectLhkRoomList(queryParams);
        return getDataTable(list);
    }

    /**
     * 导出房间信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:hotel_room:export')")
    @Log(title = "房间信息管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LhkRoom lhkRoom)
    {
        List<LhkRoom> list = lhkRoomService.selectLhkRoomList(lhkRoom);
        ExcelUtil<LhkRoom> util = new ExcelUtil<LhkRoom>(LhkRoom.class);
        util.exportExcel(response, list, "房间信息管理数据");
    }

    /**
     * 获取房间信息管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:hotel_room:query')")
    @GetMapping(value = "/{roomId}")
    public AjaxResult getInfo(@PathVariable("roomId") Long roomId)
    {
        return success(lhkRoomService.selectLhkRoomByRoomId(roomId));
    }

    /**
     * 新增房间信息管理
     */
    @PreAuthorize("@ss.hasPermi('system:hotel_room:add')")
    @Log(title = "房间信息管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LhkRoom lhkRoom)
    {
        return toAjax(lhkRoomService.insertLhkRoom(lhkRoom));
    }

    /**
     * 修改房间信息管理
     */
    @PreAuthorize("@ss.hasPermi('system:hotel_room:edit')")
    @Log(title = "房间信息管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LhkRoom lhkRoom)
    {
        return toAjax(lhkRoomService.updateLhkRoom(lhkRoom));
    }

    /**
     * 删除房间信息管理
     */
    @PreAuthorize("@ss.hasPermi('system:hotel_room:remove')")
    @Log(title = "房间信息管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{roomIds}")
    public AjaxResult remove(@PathVariable Long[] roomIds)
    {
        return toAjax(lhkRoomService.deleteLhkRoomByRoomIds(roomIds));
    }
}
